<%
# Copyright (C) 2014 - present Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
%>

<%
  @external_integration_keys ||= {}
  external_integration_keys = @external_integration_keys.select { |key_type, key| key.grants_any_right?(@current_user, :read, :write) }
%>
<% unless external_integration_keys.empty? %>
  <fieldset id="external_integration_keys">
    <h2 class="screenreader-only">{{#t}}External Integration Keys{{/t}}</h2>
    <legend>{{#t}}External Integration Keys{{/t}}</legend>
    <% external_integration_keys.each do |key_type, key| %>
      <%= f.fields_for :external_integration_keys do |external_integration_key| %>
        <div>
          <%= external_integration_key.label key_type, "#{ExternalIntegrationKey.label_for(key_type)}:" %>
          <% if key.grants_right?(@current_user, :write) %>
            <%= external_integration_key.text_field key_type, value: key.key_value %>
          <% else %>
            <span><%= key.key_value %></span>
          <% end %>
        </div>
      <% end %>
    <% end %>
  </fieldset>
<% end %>
